//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    showModal:false,
    Remarks:false,
    Remark:'',
    payfee:0
  },
  onLoad: function () {
    
  },
  addRemark:function(){
    this.setData({
      showModal: true
    })
  },
  editRemark:function(){
    this.setData({
      showModal: true
    })
  },
  modalCannel:function(){
    this.setData({
      showModal: false
    })
  },
  modalSure:function(){
    this.setData({
      showModal: false
    })
  },
  getModal:function(e){
    this.setData({
      Remarks: true,
      Remark:e.detail.value
    })
  },
  getFee:function(e){
    this.setData({
      payfee:e.detail.value
    })
  },
  payNow:function(){
    var that=this
    if(that.data.payfee>0){
      wx.request({
        url: app.globalData.baseUrl + 'api/order/orderIn', //支付接口
        data: {
          openid: app.globalData.openid,
          payfee: that.data.payfee,
          remark:that.data.Remark
        },
        header: {
          'content-type': 'application/json' // 默认值
        },
        success(tmdres) {
          wx.requestPayment({
            timeStamp: tmdres.data.data.timeStamp,
            nonceStr: tmdres.data.data.nonceStr,
            package: tmdres.data.data.package,
            signType: tmdres.data.data.signType,
            paySign: tmdres.data.data.paySign,
            success: function (respay) {
              console.log(respay)
              wx.showToast({
                title: '付款成功',
                icon:'none'
              })
            },
            fail(reserr) {
              wx.showToast({
                title: '付款失败',
                icon:'none'
              })
            }
          })
        }
      });
    }else{
      wx.showToast({
        title: '请输入金额',
        icon:'none'
      })
    }
    
  },
  onShareAppMessage:function(){
    return {
      title: '【如意气血】微信收银台',
      path: '/pages/index/index',
      imageUrl:'/img/share.png',
      success: function(res) {}
    }
  }
})
